package com.sykj.why.thread;

import com.sykj.why.mongo.document.entity.SolrDocumentT;
import com.sykj.why.mongo.service.SolrService;
import org.apache.solr.client.solrj.SolrServerException;

import java.io.IOException;

/**
 * @author Eleven
 * @date 2019/6/18
 * @desc Solr线程
 */

public class SolrThread extends Thread {

    private SolrService solrService;
    private SolrDocumentT solrDocumentT;

    public SolrThread(SolrService solrService,SolrDocumentT solrDocumentT){
        this.solrService = solrService;
        this.solrDocumentT = solrDocumentT;
    }

    @Override
    public void run() {
        synchronized (SolrThread.class) {
            try {
                solrService.add(solrDocumentT);
            } catch (IOException e) {
                e.printStackTrace();
            } catch (SolrServerException e) {
                e.printStackTrace();
            }
        }
    }

}
